﻿using ExpressesClass.Method;
using ExpressesClass.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;

namespace OFFICE_Helper.Util
{
    public class DbUtil
    {
        private static readonly string proc_kd_kddh_query = "";
        private static readonly string proc_kd_kddh_insert = "";
        private static readonly string proc_kd_kddh_cancel = "";
        private static readonly string proc_kd_kddh_print = "";
        private static readonly string text_time = "";

        #region 通用
        public static List<Kddh> Kddh_Query(DateTime time_begin, DateTime time_end, Kddh.ScenariosType scenariosType, string company)
        {
            //SqlParameter p1 = new SqlParameter("DATE_BEGIN", time_begin);
            //SqlParameter p2 = new SqlParameter("DATE_END", time_end);
            //SqlParameter p3 = new SqlParameter("SCENARIOS", scenariosType.ToString());
            //SqlParameter p4 = new SqlParameter("COMPANY", company);
            //DataTable dt = SqlHelper.ExcuteTable(proc_kd_kddh_query, CommandType.StoredProcedure, p1, p2, p3, p4);
            //if (dt != null && dt.Rows.Count > 0)
            //{
            //    return SqlHelper.GetList<Kddh>(dt);
            //}
            //return new List<Kddh>();

            return new List<Kddh>();
        }
        public static List<Sender> GetManMsg(List<Kddh> kddhs)
        {
            List<Sender> list = kddhs.Select(k => new Sender
            {
                Name = k.receiveMan,
                Phone = k.receiveManPhone,
                Address = k.receiveManAddress,
                Province = k.receiveProvince,
                City = k.receiveCity,
                County = k.receiveCounty,
                Postcode = k.receivePostcode
            }).Distinct(new LambdaQualComparer<Sender>((a, b) => a.Name == b.Name && a.Phone == b.Phone && a.Address == b.Address, obj => obj.ToString().GetHashCode())).ToList();
            list.Sort(new LambdaComparer<Sender>((a, b) => a.Name.CompareTo(b.Name)));
            return list;
        }
        public static DateTime GetTime()
        {
            //if (DateTime.TryParse(SqlHelper.ExecuteScalar(text_time, CommandType.Text).ToString(), out DateTime time))
            //{
            //    return time;
            //}
            //else
            //{
            //    return DateTime.Now;
            //}

            return DateTime.Now;
        }
        public static bool Kddh_Insert(Kddh k)
        {
            //SqlParameter p1 = new SqlParameter("orderId", k.orderId);
            //SqlParameter p2 = new SqlParameter("mailNo", k.mailNo);
            //SqlParameter p3 = new SqlParameter("mailno_zd", k.mailno_zd);
            //SqlParameter p4 = new SqlParameter("sendMan", k.sendMan);
            //SqlParameter p5 = new SqlParameter("sendManPhone", k.sendManPhone);
            //SqlParameter p6 = new SqlParameter("sendManAddress", k.sendManAddress);
            //SqlParameter p7 = new SqlParameter("sendPostcode", k.sendPostcode);
            //SqlParameter p8 = new SqlParameter("sendProvince", k.sendProvince);
            //SqlParameter p9 = new SqlParameter("sendCity", k.sendCity);
            //SqlParameter p10 = new SqlParameter("sendCounty", k.sendCounty);
            //SqlParameter p11 = new SqlParameter("sendCompany", k.sendCompany);
            //SqlParameter p12 = new SqlParameter("receiveMan", k.receiveMan);
            //SqlParameter p13 = new SqlParameter("receiveManPhone", k.receiveManPhone);
            //SqlParameter p14 = new SqlParameter("receiveManAddress", k.receiveManAddress);
            //SqlParameter p15 = new SqlParameter("receivePostcode", k.receivePostcode);
            //SqlParameter p16 = new SqlParameter("receiveProvince", k.receiveProvince);
            //SqlParameter p17 = new SqlParameter("receiveCity", k.receiveCity);
            //SqlParameter p18 = new SqlParameter("receiveCounty", k.receiveCounty);
            //SqlParameter p19 = new SqlParameter("receiveCompany", k.receiveCompany);
            //SqlParameter p20 = new SqlParameter("shipName", k.shipName);
            //SqlParameter p21 = new SqlParameter("shipVal", k.shipVal);
            //SqlParameter p22 = new SqlParameter("itemName", k.itemName);
            //SqlParameter p23 = new SqlParameter("itemWeight", k.itemWeight);
            //SqlParameter p24 = new SqlParameter("itemCount", k.itemCount);
            //SqlParameter p25 = new SqlParameter("remark", k.remark);
            //SqlParameter p26 = new SqlParameter("bm", k.bm);
            //SqlParameter p27 = new SqlParameter("wzh", k.wzh);
            //SqlParameter p28 = new SqlParameter("markDestination", k.markDestination);
            //SqlParameter p29 = new SqlParameter("sortingCode", k.sortingCode);
            //SqlParameter p30 = new SqlParameter("pkgCode", k.pkgCode);
            //SqlParameter p31 = new SqlParameter("billProvideSiteName", k.billProvideSiteName);
            //SqlParameter p32 = new SqlParameter("billProvideSiteCode", k.billProvideSiteCode);
            //SqlParameter p33 = new SqlParameter("proCode", k.proCode);
            //SqlParameter p34 = new SqlParameter("proName", k.proName);
            //SqlParameter p35 = new SqlParameter("destRouteLabel", k.destRouteLabel);
            //SqlParameter p36 = new SqlParameter("destTeamCode", k.destTeamCode);
            //SqlParameter p37 = new SqlParameter("codingMapping", k.codingMapping);
            //SqlParameter p38 = new SqlParameter("sourceTransferCode", k.sourceTransferCode);
            //SqlParameter p39 = new SqlParameter("abFlag", k.abFlag);
            //SqlParameter p40 = new SqlParameter("twoDimensionCode", k.twoDimensionCode);
            //SqlParameter p41 = new SqlParameter("codingMappingOut", k.codingMappingOut);
            //SqlParameter p42 = new SqlParameter("xbFlag", k.xbFlag);
            //SqlParameter p43 = new SqlParameter("printIcon", k.printIcon);
            //SqlParameter p44 = new SqlParameter("insuranceValue", k.insuranceValue);
            //SqlParameter p45 = new SqlParameter("kdCompany", k.kdCompanys);
            //SqlParameter p46 = new SqlParameter("scenarios", k.scenarios);
            //SqlParameter p47 = new SqlParameter("printNum", k.printNum);
            //SqlParameter p48 = new SqlParameter("payMethod", k.payMethod);
            //SqlParameter p49 = new SqlParameter("isReturnNo", k.isReturnNo == "是" ? true : false);
            //SqlParameter p50 = new SqlParameter("djbhs", "");

            //int re = SqlHelper.ExecuteNonQuery(proc_kd_kddh_insert, CommandType.StoredProcedure, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46, p47, p48, p49, p50);
            //return re >= 0 ? true : false;

            return true;
        }
        public static bool Kddh_Cancel(string mailNo)
        {
            //SqlParameter p1 = new SqlParameter("mailNo", mailNo);
            //int re = SqlHelper.ExecuteNonQuery(proc_kd_kddh_cancel, CommandType.StoredProcedure, p1);
            //return re >= 0 ? true : false;

            return true;
        }
        public static bool Kddh_Print(string mailNo)
        {
            //SqlParameter p1 = new SqlParameter("mailNo", mailNo);
            //int re = SqlHelper.ExecuteNonQuery(proc_kd_kddh_print, CommandType.StoredProcedure, p1);
            //return re >= 0 ? true : false;

            return true;
        }
        #endregion
    }
}
